package com.kaifamiao.N0812;

import com.kaifamiao.N0808.MyList;

import java.util.ArrayList;
import java.util.List;


public class NewTitle {

    private int id = 1;

    private String titleName;

    private String author;

    public NewTitle() {
    }

    public NewTitle(int id, String titleName, String author) {
        this.id = id;
        this.titleName = titleName;
        this.author = author;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitleName() {
        return titleName;
    }

    public void setTitleName(String titleName) {
        this.titleName = titleName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @Override
    public String toString() {
        return "NewTitle{" +
                "id=" + id +
                ", titleName='" + titleName + '\'' +
                ", author='" + author + '\'' +
                '}';
    }
}

class Test01 {
    public static void main(String[] args) {

        NewTitle car1 = new NewTitle(1, "兰博基尼", "梁全年");
        NewTitle car2 = new NewTitle(2, "玛莎拉蒂", "魏域江");

        List newsTitleList = new ArrayList();

        newsTitleList.add(car1);
        newsTitleList.add(car2);

        System.out.println(newsTitleList.size());
        System.out.println();
        for(Object obj:newsTitleList){

            NewTitle newTitle = (NewTitle)obj;

            System.out.println(newTitle.getTitleName());
            System.out.println(newTitle.toString());
        }


    }
}









